package com.gsafety.xlibrary

import android.view.LayoutInflater
import android.view.ViewGroup
import com.gsafety.library.Base.IBaseAdapter
import com.gsafety.library.Base.BaseHolder

class AdapterI : IBaseAdapter<Any>()
{
    override fun onCreate(parent: ViewGroup, viewType: Int): BaseHolder
    {
        val inflater = LayoutInflater.from(parent.context)
        val view = inflater.inflate(
            if (viewType == 0) R.layout.item_list_1 else R.layout.item_list_2,
            parent,
            false
        )
        return BaseHolder(view)
    }

    override fun onBindView(holder: BaseHolder, data: Any, position: Int) = Unit

    override fun getItemViewType(position: Int): Int
    {
        return when (list[position])
        {
            is String -> 0
            else -> 1
        }
    }

    override fun getViewTypeCount() = 2
}